#include <iostream>
#include <string>
using namespace std;
const int N = 1e3 + 10;
int f[N][N];
// zdl:: 和其他的填表背包不同的是，区间dp有自己特有的填表方式
int main()
{
    string s;
    cin >> s;
    int n = s.size();
    s = " " + s;
    for (int len = 1; len <= n; len++)
    {
        for (int i = 1; i  + len - 1 <= n; i++)
        {
            int j = i + len - 1;
            if (s[i] == s[j]) f[i][j] = f[i + 1][j - 1];
            else 
            {
                f[i][j] = min(f[i][j - 1] + 1 , f[i + 1][j] + 1);
            }
        }
    }

    cout << f[1][n] << endl;
    return 0;
}